<template>
  <div class="block pagination">
    <el-pagination :current-page="pageData.pageNo" :page-sizes="pageData.pageSizes" :page-size="pageData.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageData.total" @size-change="pageSizeChange" @current-change="pageNoChange" />
  </div>
</template>
<script>
import { global } from '../../filter/global-api'
import _common from '../../framework/commonJs/wptx_common'
import _tools from '../commonJs/wptx_tools';
const _FUNCTION_NAME = _common.pageName.WPTXPAGE
export default {
  props: {},
  data() {
    return {
      pageData: {
        pageNo: _common.page_common.PAGE_NO,
        pageSize: _common.page_common.PAGE_SIZE,
        total: 1,
        pageSizes: [10, 20, 50, 100]
      },
      otherData: {}
    }
  },
  methods: {
    pageSizeChange(val) {
      const self = this
      self.pageData.pageNo = 1
      self.pageData.pageSize = val
      self.search()
    },
    pageNoChange(val) {
      const self = this
      self.pageData.pageNo = val
      self.pageData.pageSize = self.pageData.pageSize
        ? self.pageData.pageSize
        : 10
      self.search()
    },
    search() {
      const self = this
      this.$emit('search', { pageData: self.pageData })
    },
    updatePageData(data) {
      const self = this
      self.pageData.pageNo = data.pageNo
      self.pageData.pageSize = data.pageSize
      self.pageData.total = data.totalCount
    },
    resetPageNo() {
      const self = this
      self.pageData.pageNo = _common.page_common.PAGE_NO
    }
  }
}
</script>
